<?php echo $this->render('/manage/header.phtml');?>
<link rel="stylesheet"
	href="<?php echo APPLICATION_PUBLIC_PATH;?>/kindeditor/themes/default/default.css" />
<script type="text/javascript" charset="utf-8" src="<?php echo APPLICATION_PUBLIC_PATH;?>/kindeditor/upload.js"></script>
<script charset="utf-8" src="<?php echo APPLICATION_PUBLIC_PATH;?>/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript">
    var editor;
    $(function() {
        $('#addPic').click(function() {
            var id = $('#countRow').val();
            var currid = parseInt(id) + 1;
            $('#countRow').val(currid);
            var arr = [];
            arr.push('<tr><td>');
            arr.push(id + '</td><td><input id="title');
            arr.push(id + '" type="text" style="width:100%;" name="title');
            arr.push(id + '" /></td><td><input id="description');
            arr.push(id + '" type="text" style="width:100%;" name="description');
            arr.push(id + '" /></td><td><input id="detailUrl');
            arr.push(id + '" type="text" style="width:100%;" name="imageUrl');
            arr.push(id + '" /></td><td><input id="imageUrl');
            arr.push(id + '" type="text" style="width:100%;" name="detailUrl');
            arr.push(id + '" /></td></tr>');
            var html = arr.join("");
            $('#sliderTable').append(html);
        });

        //实例化编辑器
		KindEditor.ready(function(K) {
			editor = K.create('textarea[name="content"]', {
				allowFileManager : true
			});
		});
    });
</script>
</head>
<body>
	<div id="body-wrapper">
		<?php echo $this->render('/manage/sidebar.phtml');?>
		<div id="main-content">
			<h2>首页管理</h2>
			<div class="clear"></div>
			<div class="content-box">
				<div class="content-box-header">
					<h3>Content box</h3>
					<div class="clear"></div>
				</div>
				<div class="content-box-content">
					<div class="tab-content default-tab" id="tab1">
						<h1 class="title"><?php echo $this->title;?></h1>
						<div class="content">
							<p id="msg"
							style="color: red; font-size: 18px; font-weight: bold;">
								<?php echo $this->errormsg;?>
							</p>
							<p>图片上传工具：点击“批量图片上传”图标，在弹出框中点击“添加图片”，选择完一张图片之后再点击“添加图片”，就可以批量上传图片了，点击“开始上传”完成上传，点击“全部插入”回到页面，然后会出现你上传的图片，接下来是最关键的一步，你需要点击上传图片按钮前面的“HTML代码”，将img src="/public/kindeditor/php/../attached/image/20130721/20130721141339_10486.jpg" alt=""中的src的内容即/public/kindeditor/php/../attached/image/20130721/20130721141339_10486.jpg为图片路径拷贝到编辑器下面的“图片地址”中，一条路径为一张图片。</p>
							<textarea name="content" style="width:1000px;height:250px;visibility:hidden;"></textarea>
							<br />
							<form name="homepage"
							action="<?php echo APPLICATION_ACTION_PATH . "/manage/mod-homepage-slider";?>"
							method="post">
								<table width="900px" border="1px" cellspacing="0"
								id="sliderTable">
									<tr>
										<th colspan="5">首页图片轮转设置</th>
									</tr>
									<tr>
										<th width="5%">编号</th>
										<th width="10%">图片标题</th>
										<th width="25%">图片描述</th>
										<th width="30%">图片地址</th>
										<th width="30%">点击图片跳转地址</th>
									</tr>
									<?php
        $slider = $this->slider;
        $sliderTable = $this->sliderTable;
        $count = 1;
        foreach ($slider as $pic) {
            ?>
									<tr>
										<td><?php echo $count;?></td>
										<td>
										<input id="title<?php echo $count;?>" type="text"
										style="width:100%;" name="title<?php echo $count;?>"
										value="<?php echo $pic[$sliderTable->title];?>" />
										</td>
										<td>
										<input id="description<?php echo $count;?>" type="text"
										style="width:100%;" name="description<?php echo $count;?>"
										value="<?php echo $pic[$sliderTable->description];?>" />
										</td>
										<td>
										<input id="imageUrl<?php echo $count;?>" type="text"
										style="width:100%;" name="imageUrl<?php echo $count;?>"
										value="<?php echo $pic[$sliderTable->imageUrl];?>" />
										</td>
										<td>
										<input id="detailUrl<?php echo $count;?>" type="text"
										style="width:100%;" name="detailUrl<?php echo $count;?>"
										value="<?php echo $pic[$sliderTable->detailUrl];?>" />
										</td>
									</tr>
									<?php
            $count ++;
        }
        ?>
								</table>
								<p>
									<input id="countRow" type="hidden"
									value="<?php echo $count;?>" />
									<input id="addPic"
									type="button" value="添加一张图片" />
									<input type="submit"
									value="确定" />
								</p>
							</form>
							<br />
						</div>
					</div>
				</div>
			</div>
			<div class="clear"></div>
			<?php echo $this->render('/manage/footer.phtml');?>
		</div>
	</div>
</body>
</html>